package com.lanou.utp.controller;

import com.lanou.utp.entity.*;
import com.lanou.utp.service.OptionService;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author MaQingYun
 */
@RestController
public class OptionController {

    @Resource
    private OptionService optionService;

    @ApiOperation("获取学期")
    @GetMapping("/option/semester")
    public ResponseData getSemester() {
        List<Teachlink> semesterList = this.optionService.getSemester();
        return new ResponseData("ok", semesterList);
    }

    @ApiOperation("获取基地id,name,坐标")
    @GetMapping("/option/base")
    public ResponseData getBase() {
        List<Base> baseList = this.optionService.getBase();
        return new ResponseData("ok", baseList);
    }

    @GetMapping("/option/major/teachers")
    public ResponseData getTeachers() {
        Long id = 1L;
        //Todo 需要确认登录用户的专业id
        List<Teacher> teacherList = this.optionService.getTeachers(id);
        return new ResponseData(teacherList);
    }

    @ApiOperation("根据基地id, 获取该基地的老师列表")
    @GetMapping("option/base/{id}/teachers")
    public ResponseData adviserTeahcers (@PathVariable Long id) {
        List<Teacher> teacherList = this.optionService.adviserTeahcers(id);
        return new ResponseData(teacherList);
    }

    @ApiOperation("获取学院的所有学生")
    @GetMapping("/option/major/students")
    public ResponseData getAllStudents() {
        long majorId = 1L;
        //TODO 需要获取当前用户的majorid
        List<Student> studentList = this.optionService.getAllStudentsByMajorId(majorId);
        return new ResponseData(studentList);
    }


}
